package com.neusoft.resturant.controller;

import com.neusoft.resturant.entity.Student;
import com.neusoft.resturant.mapper.StudentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author: Daniel
 * @date: 2023-10-18 14:56
 **/
@RestController
@RequestMapping("/api")
public class FirstController {

    @Value("${com.mysql.user}")
    private String user;

    @Value("${com.mysql.password}")
    private String password;

    @GetMapping("/yml")
    public String testYml() {
        return this.user + this.password;
    }

    @Autowired
    private StudentMapper studentMapper;

    @GetMapping("/show")
    public Student show() {
        Student student = new Student();
        student.setSno("210000305");
        student.setName("卢杰");
        student.setSex("男");
        return student;
    }


    @GetMapping("/student/all")
    public Object studentList() {
        List<Student> list = studentMapper.queryAll();
        return list;
    }

}